package com.jic.member.impl;

import java.lang.Long;
import java.util.List;

import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;
import com.jic.member.entity.RuleConsume;
import com.jic.member.mapper.RuleConsumeMapper;
import com.jic.member.service.RuleConsumeService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 积分消耗规则详情表
 * @author : 
 * @email : 
 * @since : 2020-01-15 08:28:40
 * @version : v1.0.0
 */
@Service
public class RuleConsumeServiceImpl implements RuleConsumeService {

    @Autowired
    private RuleConsumeMapper ruleConsumeMapper;

    @Override
    public long insert(RuleConsume ruleConsume) {
        long flag = ruleConsumeMapper.insert(ruleConsume);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return ruleConsumeMapper.delete(id);
    }

    @Override
    public long deleteByRuleInfoId(Long ruleInfoId) {
        return ruleConsumeMapper.delete(ruleInfoId);
    }

    @Override
    public long update(RuleConsume ruleConsume) {
        return ruleConsumeMapper.update(ruleConsume);
    }

    @Override
    public long updateByRuleInfoId(RuleConsume ruleConsume) {
        return ruleConsumeMapper.updateByRuleInfoId(ruleConsume);
    }

    @Override
    public RuleConsume queryByPrimaryKey(Long id){
        return ruleConsumeMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<RuleConsume> query(RuleConsume ruleConsume){
        return ruleConsumeMapper.query(ruleConsume);
    }

    @Override
    public PageResult<RuleConsume> queryPage(RuleConsume ruleConsume, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<RuleConsume> list = ruleConsumeMapper.queryPage(startIndex, pageQuery.getLimit(), ruleConsume);
        long count = ruleConsumeMapper.queryPageCount(ruleConsume);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }
}